package cn.kgc.crowdfundingadmin03.service;

import cn.kgc.crowdfundingadmin03.mapper.MessageMapper;
import cn.kgc.crowdfundingadmin03.pojo.*;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class MessageServiceImpl implements MessageService {

    @Resource
    MessageMapper messageMapper;

    @Override
    public PageInfo<Message> queryForKeywordWithPage(Integer pageNum, Integer pageSize, String keyword) {
        //进行分页的查询
        //1.开启分页功能
        PageHelper.startPage(pageNum,pageSize);
        //2.执行查询
        MessageExample example=new MessageExample();
        MessageExample.Criteria criteria = example.createCriteria();
        //跟据名字查询  模糊

        List<Message> list = messageMapper.selectByExample(example);
        PageInfo<Message> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public void updateRole(Message advertisement) {
        messageMapper.updateByPrimaryKeySelective(advertisement);
    }

    @Override
    public List<Message> getRoleListByIdList(List<Integer> roleIdList) {
        MessageExample example=new MessageExample();
        MessageExample.Criteria criteria = example.createCriteria();
        criteria.andIdIn(roleIdList);
        List<Message> roles = messageMapper.selectByExample(example);
        return roles;
    }


}
